//
//  UINavigationController+Utility.m
//  MyLawyerFoundation
//
//  Created by Jinxiao on 8/29/15.
//
//

#import "UINavigationController+Utility.h"

@implementation UINavigationController (Utility)

- (void)popToViewControllerWithClass:(Class)class_
{
    __block UIViewController *viewController = nil;
    [self.viewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        if([obj isKindOfClass:class_])
        {
            viewController = obj;
            *stop = YES;
        }
    }];
    
    if(viewController != nil)
    {
        [self popToViewController:viewController animated:YES];
    }
    else
    {
        [self popToRootViewControllerAnimated:YES];
    }
}

@end
